package br.com.gestantes.controle;

import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import br.com.gestantes.modelo.Estoque;

/**
 * Handles requests for the application home page.
 */
@Controller
public class EstoqueController {
	
	private static final Logger logger = LoggerFactory.getLogger(EstoqueController.class);
	
	/**
	 * Simply selects the estoque view to render by returning its name.
	 */
	@RequestMapping(value = "/estoque", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		logger.info("Estoque Controller.");
				
		Estoque estoque = new Estoque();
	    
	    model.addAttribute("products", estoque.getQuantidades());
		
		model.addAttribute("product", "Placa de Madeira" );
		
		return "estoque";
	}
	
	@RequestMapping(value = "/cutWood", method = RequestMethod.POST)
	public String cutWood(Locale locale, Model model) {
		logger.info("Cortando Madeira.");
		
		//TODO Passar para banco de dados
		Estoque estoque = new Estoque();
	    
	    model.addAttribute("products", estoque.getQuantidades());
		
		model.addAttribute("product", "Madeira Cortada" );
		
				
		return "estoque";
	}
	
}
